import cv2
import matplotlib.pyplot as plt
image=cv2.imread("river.png")
image_Gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
t1,dst1=cv2.threshold(image_Gray,127,255,cv2.THRESH_BINARY)
t2,dst2=cv2.threshold(image_Gray,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
print(t2)
hist=cv2.calcHist([image_Gray],[0],None,[256],[0,255])
plt.plot(hist)
plt.show()
cv2.imshow('Input',image)
cv2.imshow('BINARY',dst1)
cv2.imshow('OTSU',dst2)
cv2.waitKey()
cv2.destroyAllWindows()